#include "appsettings.h"
#include <QSettings>
#include <QCoreApplication>

AppSettings::AppSettings()
{

}

QString AppSettings::getFileName()
{
    QString fileName = QCoreApplication::applicationName();
    fileName += ".ini";
    return fileName;
}

bool AppSettings::get(const QString& key, QString& value)
{
    QString fileName = getFileName();

    QSettings settings(fileName, QSettings::IniFormat);
    if (!settings.contains(key))
    {
        return false;
    }

    value = settings.value(key).toString();
    return true;
}

bool AppSettings::set(const QString& key, const QString& value)
{
    QString fileName = getFileName();

    QSettings settings(fileName, QSettings::IniFormat);
    settings.setValue(key, value);
    return true;
}

